/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package towerdefence.model;

import net.phys2d.math.Vector2f;
import net.phys2d.raw.Body;
import net.phys2d.raw.shapes.Shape;

/**
 *
 * @author Gussoh
 */
public abstract class Destructible extends Body {

    public Destructible(Shape shape, float m) {
        super(shape, m);

    }

    /**
     * 
     * @return the energy (e=mv^2) this body can handle without breaking
     */
    public abstract double getStrength();

    public abstract void destroyedBy(Body other, double energy);

    /*@Override
    public strictfp void collided(Body other) {
        super.collided(other);

        Vector2f relativeVelocity = new Vector2f(getVelocity());
        relativeVelocity.sub(other.getVelocity());
        
        // dirty hack
        Body movingBody = other.getVelocity().lengthSquared() > getVelocity().lengthSquared() ? other : this;
        
        double energy = relativeVelocity.lengthSquared() * movingBody.getMass();
        if (energy > getStrength()) {
            System.out.println("---");
            System.out.println("energy: " + energy);
            System.out.println("Strength was: " + getStrength());
            System.out.println("---");
            destroyedBy(other, energy);
        }
    }*/
}
